package collectiondemo;

public class ArrayToCollection1 {
    public static void main(String[] args) {
        int n = 5;         // 5 个元素
        String[] name = new String[n];
        for (int i = 0; i < n; i++) {
            name[i] = String.valueOf(i);
        }
//        不建议这样写
//        java.util.List<String> list = java.util.Arrays.asList(name);
        java.util.List<String> list = new java.util.ArrayList<>(java.util.Arrays.asList(name));

        System.out.println();
        for (String li : list) {
            String str = li;
            System.out.print(str + " ");
        }
    }
}
